package DBLayer;

/**
 * GetMax.java
 * @author Brian Lassen
 * @version 20. Marts 2012
 */
import java.sql.ResultSet;
import java.sql.Statement;

public class GetMax 
{
    
    public GetMax() 
    {
    }
			
    public static int getMaxId(String query)
    {
    	ResultSet results;
    	int id = -1;
    	try
    	{ 
    		Statement stmt = DBConnection.getInstance().getDBcon().createStatement();
    		results = stmt.executeQuery(query);
    		if( results.next() )
    		{
    			id = results.getInt(1);
    		}
	    }	
    	catch(Exception e)
    	{
    		System.out.println("Query exception: Error in reading maxid" + e);
    	}
    	
    	return id;
    }
}
